
Page({
  data:{
    tourist:[
      {
        name:"张三",
        id:"13043041468681414",
        tel:"13463074934"
      },
      {
        name:"李四",
        id:"13043041468681414",
        tel:"13463074934"
      },
      {
        name:"李明",
        id:"13043041468681414",
        tel:"13463074934"
      },
      {
        name:"王思宇",
        id:"13043041468681414",
        tel:"13463074934"
      },
      {
        name:"李启明",
        id:"13043041468681414",
        tel:"13463074934"
      },
      {
        name:"宗四名",
        id:"13043041468681414",
        tel:"13463074934"
      },
      {
        name:"李儒",
        id:"13043041468681414",
        tel:"13463074934"
      },
      {
        name:"万艾可",
        id:"13043041468681414",
        tel:"13463074934"
      },
      {
        name:"方向",
        id:"13043041468681414",
        tel:"13463074934"
      }
    ],
    isselect:[],
    selected:{
      length:0
    }
  },
  select(e){
    var index = e.target.dataset.i;
    var cdata = this.data.isselect; 
    cdata[index] = !cdata[index]
    this.setData({
      isselect:cdata
    })
    console.log(this.data.isselect[index])
    var selected = this.data.selected;
    if(this.data.isselect[index]){
      selected[index] = this.data.tourist[index]
      selected.length = selected.length+1
    }else{
      delete selected[index];
      selected.length = selected.length-1
    }
    this.setData({
      selected:selected
    })
    console.log(this.data.selected)
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})